#include <iostream>
using namespace std;
double func (double n, double a, double b, double c)
{
	return a*n*n + b*n + c;
}
int main()
{
	double a, b, c;
	double d, e, f, n;
	cin >> d >> e >> f >> n;
	a = (f-2*e+d)/2;
	b = e-a-d;
	c = d;
	cout << func(n, a, b, c) << endl;
	return 0;
}
